#include "Calc.h"

std::string Calc::m_input  = "";              //Change this to QString
unsigned int Calc::m_nParentesis = 0;
std::vector<Operator> Calc::m_stack;

Calc::Calc(){}

void
Calc::clicked(short clicked){
    OpType clk = (OpType)clicked;

    if (clicked<0) applyOperation(clk);  //One input operators
    if(clicked<=9) {                     //Not operators
        insertNumber(clicked);
    } else {                             //Two input operators or special operations
        switch(clk) {
            case CLEAR: {
                clear();
                break;
            }
            case TOOGLE:{
                inputSignToogle();
                break;
            }
            case CLOSE_PARENTESIS:{
                if (m_nParentesis > 0) {
                    //Evaluate parentesis group
                    m_nParentesis--;
                    m_input = eval();
                }
                break;
            }
            case OPEN_PARENTESIS:{
                ++m_nParentesis;
                pushOperator(OPEN_PARENTESIS,0);
                break;
            }
            default:{
                pushOperator(clk, m_input);
                break;
            }
        }
    }
}


void
Calc::pushOperator(OpType ot, std::string value){
    //Create new operator
    //Check if the new priority is lower or equal the top
    //yes
        //Eval and then pile operator(ot,result)
    //no
        //Just pile
}

void
Calc::insertNumber(short digit){
}

void
Calc::inputSignToogle(){
}

void
Calc::clear(){
}

void
Calc::putDot(){
}

void
Calc::applyOperation(OpType op){
}

std::string                        //TODO:CHANGE TO QSTRING
Calc::eval(){
}


